function ccR_Priest_1()
	if SpellIsTargeting() == 1 then SpellStopTargeting() end

--	ccrCastBuffIfMissing(POWER_WORD_FORTITUDE)
	ccrCastBuffIfMissing(INNER_FIRE)

	-- Wait until casting is over 
	if ccrPlayerIsCastingOrChanneling() then return end
	--

	-- Survival
	if ccrPlayerIsInCombat()
	and not IsInGroup()
	and not IsInRaid()
	then
		if ccrPlayerHealth() <= 30
		and ccrPlayerHasTalent(DESPERATE_PRAYER)
		and ccrSpellIsReady(DESPERATE_PRAYER)
		then
			ccrCast(DESPERATE_PRAYER, "Player")
			return
		elseif ccrPlayerHealth() <= 40
		and ccrPlayerHasSpell(PAIN_SUPPRESSION)
		and ccrSpellIsReady(PAIN_SUPPRESSION)
		then
			ccrCast(PAIN_SUPPRESSION, "Player")
			return
		elseif ccrPlayerHealth() <= 50
		and ccrPlayerHasSpell(PENANCE)
		and ccrSpellIsReady(PENANCE)
		then
			ccrCast(PENANCE, "Player")
			return
		elseif ccrPlayerHealth() <= 60
		and ccrPlayerHasSpell(POWER_WORD_SHIELD)
		and ccrSpellIsReady(POWER_WORD_SHIELD)
		and not ccrPlayerHasDebuff(WEAKENED_SOUL)
		then
			ccrCast(POWER_WORD_SHIELD, "Player")
			return
		elseif ccrPlayerHealth() <= 80
		and ccrPlayerHasSpell(RENEW)
		and ccrSpellIsReady(RENEW)
		and not ccrPlayerHasBuff(RENEW)
		then
			ccrCast(RENEW, "Player")
			return
		end
	end
	--------------------------
	-- Find all nearby players
	Gather_Nearby_Players()
	--------------------------
	-- Find who has the lowest health
	local vPlayerToHeal, vPlayerHealth = Find_Lowest_HP()
	if vPlayerToHeal ~= nil
	and vPlayerHealth ~= nil
	and (IsInGroup() or IsInRaid())
	then
		if ccrUnitHasDebuff(vPlayerToHeal, "Strong Ancient Barrier", "any") then vPlayerHealth = 60 end
		if ccrUnitHasDebuff(vPlayerToHeal, "Ancient Barrier", "any") then vPlayerHealth = 40 end
		if ccrUnitHasDebuff(vPlayerToHeal, "Weak Ancient Barrier", "any") then vPlayerHealth = 20 end	

		if ccrPlayerIsInCombat() then
			-- Arcangel
			if ccrPlayerHasBuffStacks(EVANGELISM, 5)
			and ccrSpellIsReady(ARCHANGEL)
			then
				ccrCast(ARCHANGEL)
				return
			end
			-- Inner Focus
			if ccrSpellIsReady(INNER_FOCUS) then ccrCast(INNER_FOCUS) end
		end
		--
		-- Emergency
		--
			-- Prayer of Healing for Spirit Shell
			local i
			if ccrPlayerHasBuff(109964)
			and not ccrPlayerIsMoving()
			and ccrSpellIsReady(PRAYER_OF_HEALING)
			then
				for i = 0, # tblNearbyPlayers do
					if not ccrUnitHasBuff(tblNearbyPlayers[i], SPIRIT_SHELL) then 
						ccrCast(PRAYER_OF_HEALING, tblNearbyPlayers[i])
						return
					end
				end	
			end
		--
		-- Bubble All
		--
			if ccrPlayerHasBuff(INNER_FOCUS)
			and ccrSpellIsReady(PRAYER_OF_HEALING)
			and ccrPlayerIsInCombat()
			and not ccrPlayerIsMoving()
			and (vLastPrayerOfHealing == nil or (GetTime()-vLastPrayerOfHealing > 3.0))
			then
				ccrCast(PRAYER_OF_HEALING, vPlayerToHeal)
				vLastPrayerOfHealing = GetTime()
				return
			end		
		--
		-- TANK
		--
		if UnitGroupRolesAssigned(vPlayerToHeal) == "TANK"
		and UnitInRange(vPlayerToHeal)
		then
			-- Void Shift
			if ccrPlayerHasSpell(VOID_SHIFT)
			and vPlayerHealth <= 20
			and ccrPlayerHealth() >= 70
			and not ccrPlayerIsMoving()
			and ccrSpellIsReady(VOID_SHIFT)
			then
				ccrCast(VOID_SHIFT, vPlayerToHeal)
				return
			end
			-- Prayer of Mending
			if IsInRaid() then
				if vPlayerHealth <= 100
				and ccrSpellIsReady(PRAYER_OF_MENDING)
				and GroupedPlayersHealth(vPlayerToHeal, 30, 90) >= 4
				then
					ccrCast(PRAYER_OF_MENDING, vPlayerToHeal)
					return
				end
			else
				if vPlayerHealth <= 100
				and ccrSpellIsReady(PRAYER_OF_MENDING)
				then
					ccrCast(PRAYER_OF_MENDING, vPlayerToHeal)
					return
				end
			end
			-- Binding Heal
			if vPlayerHealth <= 20
			and ccrPlayerHealth() <= 60
			and not ccrPlayerIsMoving()
			and ccrSpellIsReady(BINDING_HEAL)
			then
				ccrCast(BINDING_HEAL, vPlayerToHeal)
				return
			end
			-- Power Word: Shield
			if vPlayerHealth <= 60
			and not ccrUnitHasBuff(vPlayerToHeal, POWER_WORD_SHIELD) 
			and not ccrUnitHasDebuff(vPlayerToHeal, WEAKENED_SOUL)
			and ccrSpellIsReady(POWER_WORD_SHIELD)
			then
				ccrCast(POWER_WORD_SHIELD, vPlayerToHeal)
				return
			end
		end
		--
		-- Groups
		--
			local vTemp = 2
			-- Still performing DPS to heal
			if ccrValidTarget() then
				-- Prayer of Healing with Inner Focus	
				if IsInRaid() then vTemp = 8 else vTemp = 2 end
				if ccrPlayerHasBuff(INNER_FOCUS) 
				and not ccrPlayerIsMoving()
				and GroupedPlayersHealth(vPlayerToHeal, 30, 95) >= vTemp
				and ccrSpellIsReady(PRAYER_OF_HEALING)
				then
					ccrCast(PRAYER_OF_HEALING, vPlayerToHeal) 
					return
				end	

				-- Prayer of Healing
				if IsInRaid() then vTemp = 10 else vTemp = 3 end
				if ccrSpellIsReady(PRAYER_OF_HEALING)
				and not ccrPlayerIsMoving()
				and	GroupedPlayersHealth(vPlayerToHeal, 30, 70) >= vTemp
				then
					ccrCast(PRAYER_OF_HEALING, vPlayerToHeal)
					return	   
				end
			else
				-- No target to dps for some reason

				-- Prayer of Healing
				if IsInRaid() then vTemp = 10 else vTemp = 2 end
				if ccrSpellIsReady(PRAYER_OF_HEALING)
				and not ccrPlayerIsMoving()
				and	GroupedPlayersHealth(vPlayerToHeal, 30, 70) >= vTemp
				then
					ccrCast(PRAYER_OF_HEALING, vPlayerToHeal)
					return	   
				end
				-- Heal
				if vPlayerHealth <= 95
				and not ccrPlayerIsMoving()
				and ccrSpellIsReady(HEAL)
				then
					ccrCast(HEAL, vPlayerToHeal)
					return	   
				end
			end
			-- Divine Star
			if IsInRaid() then vTemp = 8 else vTemp = 3 end
			if ccrPlayerHasSpell(DIVINE_STAR)
			and ccrSpellIsReady(DIVINE_STAR)
			and	GroupedPlayersHealth(vPlayerToHeal, 40, 95) >= vTemp
			then
				ccrCast(DIVINE_STAR)
				return
			end

			-- Halo
			if IsInRaid() then vTemp = 10 else vTemp = 2 end
			if ccrPlayerHasSpell(HALO)
			and ccrSpellIsReady(HALO) 
			and	GroupedPlayersHealth(vPlayerToHeal, 40, 70) >= vTemp
			then
				ccrCast(HALO)
				return
			end
		--
		-- REST
		--
			-- Penance
			if vPlayerHealth <= 30
			and ccrSpellIsReady(PENANCE)
			then
				ccrCast(PENANCE, vPlayerToHeal)
				return
			end

			-- Flash Heal
			if vPlayerHealth <= 20
			and not ccrPlayerIsMoving()
			and ccrSpellIsReady(FLASH_HEAL)
			then
				ccrCast(FLASH_HEAL, vPlayerToHeal)
				return
			end

			if not IsInRaid() then
				-- PW:S Any mob below 50%
				if vPlayerHealth <= 50
				and not ccrUnitHasBuff(vPlayerToHeal, POWER_WORD_SHIELD)
				and not ccrUnitHasDebuff(vPlayerToHeal, WEAKEND_SOUL)
				and ccrSpellIsReady(POWER_WORD_SHIELD)
				then
					ccrCast(POWER_WORD_SHIELD, vPlayerToHeal)
					return
				end
			end
			-- Heal when mana under 20%
			if vPlayerHealth <= 90
			and not ccrPlayerIsMoving()
			and ccrPlayerMana() <= 20
			and ccrSpellIsReady(HEAL)
			then
				ccrCast(HEAL, vPlayerToHeal)
				return	   
			end
	-- end of find lowest hp
	end

	if PlayerIsSOLO() then
		-- PW:S if getting ragged
		if ccrPlayerHasSpell(POWER_WORD_SHIELD)
		and ccrSpellIsReady(POWER_WORD_SHIELD)
		and (not ccrPlayerHasBuff(POWER_WORD_SHIELD) or ccrPlayerHasDebuff(WEAKENED_SOUL))
		then
			local x
			if # tblPGetMeleeEnemies > 0 then
				for x = 0, # tblPGetMeleeEnemies do
					local obj = tblPGetMeleeEnemies[x]
					if obj
					and obj:Exists()
					and (obj:GetTarget():Exists() and obj:GetTarget():GetName() == ccrPlayerName())
					then
						ccrCast(POWER_WORD_SHIELD, "Player")
						return
					end
				end
			end
		end
	end

	-- Angelic Feather
	if IsMounted() == nil
	and ccrSpellIsReady(ANGELIC_FEATHER)
	and not ccrPlayerHasBuff(ANGELIC_FEATHER)
	and ccrPlayerIsMoving()
	then
		ccrCast(ANGELIC_FEATHER)
		if SpellIsTargeting() == 1 then CastAtLocation(Player:GetLocation()) end
		return
	end

	-- Mindbender
	if ccrPlayerHasSpell(SHADOWFIEND) 
	and ccrSpellIsReady(SHADOWFIEND)
	and ccrPlayerMana() <= 90
	and ccrValidTarget()
	and ccrSpellCanAttack(SHADOWFIEND)
	then
		ccrCastAttack(SHADOWFIEND)
		return
	end

	if ccrValidTarget() then
		-- Shadow Word: Death
		if ccrPlayerHasSpell(SHADOW_WORD_DEATH)
		and ccrSpellCanAttack(SHADOW_WORD_DEATH)
		and ccrTargetHealth() <= 20
		then
			ccrCastAttack(SHADOW_WORD_DEATH)
			return
		elseif ccrPlayerHasSpell(SHADOW_WORD_PAIN)
		and not ccrTargetHasMyDebuff(SHADOW_WORD_PAIN)
		and ccrSpellCanAttack(SHADOW_WORD_PAIN)
		and PlayerIsSOLO()
		then
			ccrCastAttack(SHADOW_WORD_PAIN)
			return
		elseif ccrPlayerHasSpell(HOLY_FIRE)
		and ccrSpellCanAttack(HOLY_FIRE)
		and ccrPlayerIsFacingTarget()
		then
			ccrCastAttack(HOLY_FIRE)
			return
		elseif ccrPlayerHasSpell(PENANCE)
		and ccrSpellCanAttack(PENANCE)
		and ccrPlayerIsInCombat()
		then
			ccrCastAttack(PENANCE)
			return
		elseif ccrPlayerHasSpell(SMITE)
		and ccrSpellCanAttack(SMITE)
		and not ccrPlayerIsMoving() 
		and ccrPlayerIsFacingTarget()
		then
			ccrCastAttack(SMITE) 
			return
		end	
	end
-- end of function
end